<#include "/common/header.html">
<div id="leftside">
	<div id="sidebar_s" style="border-right: 1px solid #d9dfe5;">
		<div class="collapse" style="border: none;">
			<div class="toggleCollapse">
				<div></div>
			</div>
			<!-- 隐藏菜单后的hover响应 -->
			<div class="hoverCollapse" style="height: 100%; display: none;"></div>
		</div>
	</div>
	<div id="sidebar" class="custom_tree">
		<div class="toggleCollapse" style="margin-left: -1px;">
			<h2 class="i18n" key="dwz_menu_title" place="html"><@label
				key="navigation.C">导航菜单 </@label></h2>
			<div>collapse</div>
		</div>
		<div class="accordion" fillSpace="sidebar">
			<#if menuTrees??> 
			<#list menuTrees as menus>
			<div class="accordionHeader">
				<h2>
					<span>Folder</span>${menus.menuText!''}
				</h2>
			</div>
			<div class="accordionContent">
				<ul class="treeMenu treeFolder">
				<#if menus.children ?? && menus.children ?size gt 0> 
					<@menusTree children = menus.children />
				</#if>
				</ul>
			</div>
			</#list> </#if>
			<!--
            <#if menuTrees??>
                <div id="jquery-accordion-menu" class="jquery-accordion-menu red" >
                <ul id="demo-list">
                <#list menuTrees as menus>
                    <li class="firstLev"><a href="#">${menus.menuText!''}</a>
                    <ul class="submenu">
                    <#if menus.children ?? && menus.children ?size gt 0> 
                            <@menusTree children = menus.children />
                        </#if>
                    </ul>
                    </li>
                </#list>
                </ul>
            </#if>
            -->
		</div>
	</div>
</div>
<!-- 递归产生树的宏定义 -->
<#macro menusTree children> 
	<#if children?? && children?size gt 0>
	<#list children as child> 
		<#if child.isLeaf>
		<li>
			<a href="${rc.getContextPath()}${child.url!''}?navTabId=${child.nodeId!''}"
			target="navTab" rel="${child.nodeId!''}">${child.menuText}</a>
		</li>
		<#else>
		<li>
		<a href="#">${child.menuText}</a> 
			<#if child.children?? && child.children?size gt 0>
			<ul>
			<@menusTree children=child.children />
			</ul> 
			</#if>
		</li>
		</#if> 
	</#list> 
	</#if> 
</#macro>
<div id="container">
	<div id="navTab" class="tabsPage">
		<!-- ///////////////////////////////////多标签切换/////////////////////////////////////// -->
		<div class="tabsPageHeader"
			style="margin-left: -1px; border-left: none;">
			<div class="tabsPageHeaderContent">
				<!-- 显示左右控制时添加 class="tabsPageHeaderMargin" -->
				<ul class="navTab-tab">
					<li tabid="main" class="main">
						<a href="javascript:;"><span><span class="home_icon i18n" key="dwz_navTab_main" place="html"><@label key="home.C">我的主页 </@label></span></span></a>
					</li>
				</ul>
			</div>
			<div class="tabsLeft">left</div>
			<!-- 禁用只需要添加一个样式 class="tabsLeft tabsLeftDisabled" -->
			<div class="tabsRight">right</div>
			<!-- 禁用只需要添加一个样式 class="tabsRight tabsRightDisabled" -->
			<div class="tabsMore">more</div>
		</div>
		<!-- ////////////////////////////////////////多标签精确切换 /////////////////////////////////-->
		<ul class="tabsMoreList">

		</ul>
		<div class="navTab-panel tabsPageContent layoutBox">
			<!-- ////////////////////////////////////////页面详情，每个页面都自动添加<div class="page unitBox"></div> /////////////////////////////////-->
			<div class="page unitBox">
				<div class="pageFormContent" layoutH="80" style="background: url('${rc.getContextPath()}/manage/images/index/index-bg.jpg') no-repeat; background-size: 100% 100%;">
				</div>
			</div>
		</div>
	</div>
</div>
<div id="pop" style="display: none;">
	<div id="popHead">
		<a id="popClose" title="<@label key='close.B'>关闭</@label>"
			class="close"></a>
		<h2><@label key="sysMessage.C">系统消息</@label></h2>
	</div>
	<div id="popContent">
		<dl>
			<dd id="popIntro"></dd>
		</dl>
		<p id="popMore">
			<a href="javascript:void(0);" onclick="template_message()"><@label key="viewMessage.B">查看详情 </@label></a>
		</p>
	</div>
</div>

<script type="text/javascript">
	function template_message() {
		document.getElementById("messagelist").click();
		$('#pop').hide();
	}
	$(function() {
		var count = 0;
		//建立长轮询longPolling获得消息数量
		(function longPolling() {
			$.ajax({
				type : 'POST',
				url : "${rc.getContextPath()}/manage/getMessage",
				data : {
					count : count,
					time : 60
				},
				dataType : "json",
				global : false,//禁用全局属性
				timeout : 1000 * 70, //AJAX请求超时时间为70秒  
				error : DWZ.ajaxError,
				success : function(json) {
					if (json.statusCode == DWZ.statusCode.ok) {
						if (json.data) {
							// 登陆第一次提示、或者有之前没有消息，有新消息提示
							if (count === 0) {
								new Pop("#", "<span class='messageTip'></span><@label key='have.C'>您有 </@label><span class='messageCount'>"
												+ json.data
												+ "</span><@label key='messages.C'>条新消息 ,请注意查收！</@label>");
							}
							count = json.data;
							$('#circle').addClass('twinkling');
							document.getElementById("messages").innerHTML = count;
						} else {
							count = 0;
							$('#pop').hide();
							$('#circle').removeClass('twinkling');
							document.getElementById("messages").innerHTML = "";
						}
						setTimeout(longPolling, 30000);
					}
					// 轮询请求超时或错误不做提醒，继续轮询即可
				},
				complete : function(XMLHttpRequest, status) {
					if (status == 'timeout') {
						//请求超时，继续请求 
						longPolling();
					}
				},
				error: function(e){
					console.error(e);
				}
			});
		})();
	});
	function forbidBackSpace(e) {
		var ev = e || window.event; //获取event对象         
		var obj = ev.target || ev.srcElement; //获取事件源            
		var t = obj.type || obj.getAttribute('type');
		//获取事件源类型           
		//获取作为判断条件的事件类型         
		var vReadOnly = obj.readOnly;
		var vDisabled = obj.disabled;
		//处理undefined值情况           
		vReadOnly = (vReadOnly == undefined) ? false : vReadOnly;
		vDisabled = (vDisabled == undefined) ? true : vDisabled;
		if (ev.keyCode == 113) {
			$(document).trigger('KEY_F2');
		}
		//当敲Backspace键时，事件源类型为密码或单行、多行文本的，            
		//并且readOnly属性为true或disabled属性为true的，则退格键失效           
		var flag1 = ev.keyCode == 8
				&& (t == "password" || t == "text" || t == "textarea")
				&& (vReadOnly == true || vDisabled == true);
		//当敲Backspace键时，事件源类型非密码或单行、多行文本的，则退格键失效          
		var flag2 = ev.keyCode == 8 && t != "password" && t != "text"
				&& t != "textarea";
		//判断          
		if (flag2 || flag1)
			return false;
	}
	// 禁止后退键  作用于IE、Chrome      
	document.onkeydown = forbidBackSpace;
	// 判断国际化资源和用户的权限列表是否加载
	if (!sessionStorage.getItem("resourcesAndAuthoritiesLoaded")) {
		// 获取国际化资源以及该用户的权限列表
		$.ajax({
			type : 'POST',
			url : "${rc.getContextPath()}/manage/getResourcesAndAuthorities",
			dataType : "json",
			data: {
				siteCode: '${siteCode}',
				languageCode: '${language}'
			},
			success : function(json) {
				window.buttonAuthorities = new Object();
				if (json.ButtonAuthorities) {
					$.each(json.ButtonAuthorities,function() {
						window.buttonAuthorities[this.authority.substring(7)] = true;
					});
				}
				window.localRecources = json.CommonResources;
				// 将权限数据及国际化资源保存在sessionStorage
				sessionStorage.setItem("buttonAuthorities", JSON.stringify(window.buttonAuthorities));
				sessionStorage.setItem("localRecources", JSON.stringify(window.localRecources));
				sessionStorage.setItem("resourcesAndAuthoritiesLoaded", 'true');
			}
		});
	} else {
		window.buttonAuthorities = JSON.parse(sessionStorage.getItem("buttonAuthorities"));
		window.localRecources = JSON.parse(sessionStorage.getItem("localRecources"));
	}
</script>

